package com.wht.mapper.admin.impl;

import com.wht.mapper.admin.AdminLoginDao;
import com.wht.domain.Admin;
import com.wht.utils.JDBCUtils;
import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;

/**
 * @author wanghaotian
 * time:2022/11/21,0021 19:51
 * description:
 */

public class AdminLoginDaoImpl implements AdminLoginDao {
    private JdbcTemplate jt = new JdbcTemplate(JDBCUtils.getDs());
    @Override
    public Admin selectAdmin(String username, String password) {
        try {
            String sql = "select * from admin where username=? and password=? ";
            Admin admin = jt.queryForObject(sql, new BeanPropertyRowMapper<Admin>(Admin.class), username, password);
            return admin;
        } catch (DataAccessException e) {
            return null;
        }
    }
}
